<?php

/**
 * Created by Reliese Model.
 */

namespace App\Models\System;

use App\Models\Adminer\Admins;
use Carbon\Carbon;
use App\Models\Eloquent;
use Illuminate\Http\Request;

/**
 * Class QfcOpeLog
 * 
 * @property int $id
 * @property string|null $adminer
 * @property array|null $data
 * @property string $router
 * @property string $kw
 * @property string $ope
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 *
 * @package App\Models
 */
class OpeLog extends Eloquent
{
	protected $table = 'ope_logs';

	protected $casts = [
		'data' => 'array'
	];

	protected $fillable = [
		'adminer',
		'data',
		'router',
		'kw',
		'ope'
	];

	public static function Log(Request $request, $admin_id, $kw, $ope)
    {
        $adminer = Admins::getInfoById($admin_id);
        return self::create([
            'adminer' => $adminer,
            'data' => $request->all(),
            'router' => $request->path(),
            'kw' => $kw . ',' .$request->route()->getName(), // 操作关键词
            'ope' => $ope // 操作描述
        ]);
    }
}
